package com.lil.shiro.dao;

import com.lil.shiro.model.Role;
import org.apache.ibatis.annotations.*;

import java.util.Set;

@Mapper
public interface RoleMapper extends MyBaseMapper<Role> {


    @Results(value = {
            @Result(column = "id", property = "id", id = true),
            @Result(column = "role_id", property = "roleId"),
            @Result(column = "role_name", property = "roleName"),
            @Result(column = "create_date", property = "createDate"),
            @Result(column = "update_date", property = "updateDate"),
            @Result(property = "menus", javaType = Set.class, column = "role_id",
                    many = @Many(select = "com.lil.shiro.dao.MenuMapper.getMenuByRoleId")
            )
    })
    @Select(" select r.* from user_role u ,role_info r where r.role_id = u.role_id and u.user_id = #{userId} ")
    Set<Role> getRoleByUserId(String userId);
}
